Some games frequently save the game state. When working with the blockchain, this can be expensive and involve a lot of latency. This guide addresses how to work around these constraints without impacting end user experience or over-inflating your operational expenses.
TransactionQueuer
and its inheritors provided by the Unity SDK. The TransactionQueuer
s are highly configurable and are designed to support the development of games where player’s take many state-manipulating actions. For instance, if your game involves collecting a lot of coins (or similar) as low-value transactions, you’ll likely want to make use of the PermissionedMinterTransactionQueuer
(assuming your mint
function has permissions, the default, and you are minting from a server) or the SequenceWalletTransactionQueuer
(if anyone can mint). Using these, you can simply queue up a bunch of transactions; these transactions will be automatically combined if possible (e.g. instead of having ‘mint(amount: 5, tokenId: 11)’ and ‘mint(amount: 3, tokenId: 11)’, these would get combined to ‘mint(amount: 8, tokenId: 11)’). Then, you can have your transactions be submitted ever x seconds or whenever a function call is made but no sooner than every y seconds (overrideable for high-value transactions), etc. To learn more about working with the TransactionQueuer
, please see this doc.
Finally, you’ll want to check for failures in your transactions and handle the errors appropriately.